<%--                                                                       --%>
<%-- Copyright (c) 2004-2005 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<script language="JavaScript">

function doCancel() {
  var action = '<c:url value="/ep/portletAppBrowse.do"/>';
  
  document.portletAppConfigInstallForm.action = action;
  document.portletAppConfigInstallForm.submit();
}

function doBack() {
  var action = '<c:url value="/ep/portletInstall.do"/>';
  
  document.portletAppConfigInstallForm.action = action;
  document.portletAppConfigInstallForm.submit();
}

function checkField(field,messageEmpty,messageSpaces) {
  if(field.value == "") {
     alert(messageEmpty);
     return false;
  }
  
  var tmp_string = field.value;
  for (var i=0; i < tmp_string.length; i++) {
    if(tmp_string.substring(i, i+1) != " ") {
      return true;
    }
  }
  
  alert(messageSpaces);
  return false;
}

function checkRequiredFields(form) {
  if(checkField(form.appname,'<bean:message key='ep.alert.empty.portlet.app.appname' bundle="ep.messages"/>','<bean:message key='ep.alert.portlet.app.appname.all.spaces' bundle="ep.messages"/>') == false) {
    return false;
  }
        
  <c:if test="${portletAppConfigInstallForm.map.appServer != 'jboss'}">
  if(checkField(form.host,'<bean:message key='ep.alert.empty.portlet.app.host' bundle="ep.messages"/>','<bean:message key='ep.alert.portlet.app.host.all.spaces' bundle="ep.messages"/>') == false) {
    return false;
  }
  </c:if>
  
  <c:if test="${portletAppConfigInstallForm.map.appServer == 'weblogic'}">
  if(checkField(form.port,'<bean:message key='ep.alert.empty.portlet.app.port' bundle="ep.messages"/>','<bean:message key='ep.alert.portlet.app.port.all.spaces' bundle="ep.messages"/>') == false) {
    return false;
  }

  if(checkField(form.targets,'<bean:message key='ep.alert.empty.portlet.app.targets' bundle="ep.messages"/>','<bean:message key='ep.alert.portlet.app.targets.all.spaces' bundle="ep.messages"/>') == false) {
    return false;
  }  
  
  if(checkField(form.admin,'<bean:message key='ep.alert.empty.portlet.app.admin' bundle="ep.messages"/>','<bean:message key='ep.alert.portlet.app.admin.all.spaces' bundle="ep.messages"/>') == false) {
    return false;
  }

  if(checkField(form.password,'<bean:message key='ep.alert.empty.portlet.app.password' bundle="ep.messages"/>','<bean:message key='ep.alert.portlet.app.password.all.spaces' bundle="ep.messages"/>') == false) {
    return false;
  }
  </c:if>
  <c:if test="${portletAppConfigInstallForm.map.appServer == 'websphere'}">
  if(checkField(form.wsSoapPort,'<bean:message key='ep.alert.empty.portlet.app.wsSoapPort' bundle="ep.messages"/>','<bean:message key='ep.alert.portlet.app.wsSoapPort.all.spaces' bundle="ep.messages"/>') == false) {
    return false;
  }

  if(checkField(form.wsInstanceHome,'<bean:message key='ep.alert.empty.portlet.app.wsInstanceHome' bundle="ep.messages"/>','<bean:message key='ep.alert.portlet.app.wsInstanceHome.all.spaces' bundle="ep.messages"/>') == false) {
    return false;
  }
  
  if(checkField(form.wsAppServerName,'<bean:message key='ep.alert.empty.portlet.app.wsAppServerName' bundle="ep.messages"/>','<bean:message key='ep.alert.portlet.app.wsAppServerName.all.spaces' bundle="ep.messages"/>') == false) {
    return false;
  }
  </c:if>
  <c:if test="${portletAppConfigInstallForm.map.location == 'remote'}">
  if(form.producerName.selectedIndex==0) {
    alert('<bean:message key='ep.alert.no.producer.selected' bundle="ep.messages"/>');
    return false;
  }
  </c:if>

  return true;
}

</script>

<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
  <tr>
    <td valign="top" width="100%">
      <div class="pageTitle">
      <c:if test="${portletAppConfigInstallForm.map.id == ''}">
        <bean:message key="ep.portlet.install.page.title" bundle="ep.messages"/>
      </c:if>
      <c:if test="${portletAppConfigInstallForm.map.id != ''}">
        <bean:message key="ep.portlet.reinstall.page.title" bundle="ep.messages" arg0="${portletAppConfigInstallForm.map.id}"/>
      </c:if>
      </div>
      <div class="errorMessage"><html-el:errors bundle="ep.messages"/></div>
      <%@ include file="/mc/common/pagetab.jsp" %>

      <!- place body here -->

      <html-el:form action="/ep/portletAppSave.do" onsubmit="return checkRequiredFields(this)">

      <html-el:hidden property="portletAppId" value="${portletAppConfigInstallForm.map.id}"/>
      <html-el:hidden property="portletAppPath" value="${portletAppConfigInstallForm.map.portletAppPath}"/>
      <html-el:hidden property="location" value="${portletAppConfigInstallForm.map.location}"/>
      <html-el:hidden property="serverId" value="${portletAppConfigInstallForm.map.serverId}"/>
      <html-el:hidden property="portletappaction" value="${portletAppConfigInstallForm.map.portletappaction}"/>
      
      <input type="hidden" name="forward" value="<c:out value="${epActionForward.map.forward}"/>">

      <div class="pageSubtitle">
        <span class="left"><bean:message key="ep.portlet.app.configuration" bundle="ep.messages"/></span>
        <span class="right">&nbsp;</span>
      </div>

      <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="label"><bean:message key="ep.portlet.app.appname" bundle="ep.messages"/>*:</td>
        <td class="labelField"><html-el:text property="appname" size="50" maxlength="80"/>
        </td>
      </tr>

    <c:if test="${portletAppConfigInstallForm.map.location == 'local'}">
      <c:if test="${portletAppConfigInstallForm.map.appServer != 'jboss'}">
      <tr>
        <td class="label"><bean:message key="ep.portlet.server.host" bundle="ep.messages"/>*:</td>
        <td class="labelField"><html-el:text property="host" size="50" maxlength="80"/>
        </td>
      </tr>
      </c:if>
      
      <c:if test="${portletAppConfigInstallForm.map.appServer == 'weblogic'}">
      <tr>
        <td class="label"><bean:message key="ep.portlet.server.port" bundle="ep.messages"/>*:</td>
        <td class="labelField"><html-el:text property="port" size="50" maxlength="80"/>
        </td>
      </tr>

      <tr>
        <td class="label"><bean:message key="ep.portlet.server.targets" bundle="ep.messages"/>*:</td>
        <td class="labelField"><html-el:text property="targets" size="50" maxlength="80"/>
        </td>
      </tr>

      <tr>
        <td class="label"><bean:message key="ep.portlet.server.admin" bundle="ep.messages"/>*:</td>
        <td class="labelField"><html-el:text property="admin" size="50" maxlength="80"/>
        </td>
      </tr>

      <tr>
        <td class="label"><bean:message key="ep.portlet.server.password" bundle="ep.messages"/>*:</td>
        <td class="labelField"><html-el:password property="password" size="50" maxlength="80"/>
        </td>
      </tr>
      </c:if>
      
      <c:if test="${portletAppConfigInstallForm.map.appServer == 'websphere'}">
      <tr>
        <td class="label"><bean:message key="ep.portlet.server.ws.soap.port" bundle="ep.messages"/>*:</td>
        <td class="labelField"><html-el:text property="wsSoapPort" size="50" maxlength="80"/>
        </td>
      </tr>

      <tr>
        <td class="label"><bean:message key="ep.portlet.server.ws.instance.home" bundle="ep.messages"/>*:</td>
        <td class="labelField"><html-el:text property="wsInstanceHome" size="50" maxlength="80"/>
        </td>
      </tr>

      <tr>
        <td class="label"><bean:message key="ep.portlet.server.ws.appserver.name" bundle="ep.messages"/>*:</td>
        <td class="labelField"><html-el:text property="wsAppServerName" size="50" maxlength="80"/>
        </td>
      </tr>
      </c:if>
    </c:if>
    
      <c:if test="${portletAppConfigInstallForm.map.location == 'remote'}">
      <tr>
        <td class="label"><bean:message key="ep.portlet.producer.name" bundle="ep.messages"/>*:</td>
        <td class="labelField">
            <html-el:select name="portletAppConfigInstallForm" property="producerName" size="1">
              <html-el:option key="ep.label.select" bundle="ep.messages" value="-1"/>
              <html-el:optionsCollection name="portletAppConfigInstallForm" property="producerList"/>
            </html-el:select>
        </td>
      </tr>
      </c:if>

      </table>

      <div class="pageButtonWrap" align="right">
        <input type="button" name="backBtn" class="inputButton" value="<bean:message key='button.previous' bundle="ep.messages"/>" onclick="doBack()">
        &nbsp;
        <input type="reset" name="resetBtn" value="<bean:message key='button.reset' bundle="ep.messages"/>" class="inputButton">
        &nbsp;
        <input type="button" name="cancelData" class="inputButton" value="<bean:message key='button.cancel' bundle="ep.messages"/>" onclick="doCancel()">
        &nbsp;
        <input type="submit" name="saveData" class="inputButton" value="<bean:message key='button.deploy' bundle="ep.messages"/>">
      </div>
      </html-el:form>

    </td>
  </tr>
</table>
